package com.course.design.common;

/**
 * 描述:
 *
 * @author qinlianji
 * @create 2020-02-08
 */
public class Result {
    private int code;
    private String msg;
    private Object data;
    private String url;

    private Result(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result result(int code, String msg, Object data) {
        return new Result(code, msg, data);
    }

    public static Result success(String msg, Object data) {
        return result(200, msg, data);
    }

    public static Result success(Object data) {
        return success((String)null, data);
    }

    public static Result success() {
        return success((String)null, (Object)null);
    }

    public static Result fail(String msg, Object data) {
        return result(0, msg, data);
    }

    public static Result fail(String msg) {
        return fail(msg, (Object)null);
    }

    public static Result noPermission(String msg) {
        return result(401, msg, (Object)null);
    }

    public static Result noPermission() {
        return result(401, (String)null, (Object)null);
    }

    public static Result resp(int code, String msg) {
        return result(code, msg, (Object)null);
    }

    public int getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    public Object getData() {
        return this.data;
    }

    public String getUrl() {
        return this.url;
    }

    public void setCode(final int code) {
        this.code = code;
    }

    public void setMsg(final String msg) {
        this.msg = msg;
    }

    public void setData(final Object data) {
        this.data = data;
    }

    public void setUrl(final String url) {
        this.url = url;
    }

    @Override
    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof Result)) {
            return false;
        } else {
            Result other = (Result)o;
            if (!other.canEqual(this)) {
                return false;
            } else if (this.getCode() != other.getCode()) {
                return false;
            } else {
                label49: {
                    Object this$msg = this.getMsg();
                    Object other$msg = other.getMsg();
                    if (this$msg == null) {
                        if (other$msg == null) {
                            break label49;
                        }
                    } else if (this$msg.equals(other$msg)) {
                        break label49;
                    }

                    return false;
                }

                Object this$data = this.getData();
                Object other$data = other.getData();
                if (this$data == null) {
                    if (other$data != null) {
                        return false;
                    }
                } else if (!this$data.equals(other$data)) {
                    return false;
                }

                Object this$url = this.getUrl();
                Object other$url = other.getUrl();
                if (this$url == null) {
                    if (other$url != null) {
                        return false;
                    }
                } else if (!this$url.equals(other$url)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof Result;
    }

    @Override
    public int hashCode() {
        int result = 1;
        result = result * 59 + this.getCode();
        Object $msg = this.getMsg();
        result = result * 59 + ($msg == null ? 43 : $msg.hashCode());
        Object $data = this.getData();
        result = result * 59 + ($data == null ? 43 : $data.hashCode());
        Object $url = this.getUrl();
        result = result * 59 + ($url == null ? 43 : $url.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return "Result(code=" + this.getCode() + ", msg=" + this.getMsg() + ", data=" + this.getData() + ", url=" + this.getUrl() + ")";
    }
}
